<script setup>
import { onMounted, ref } from 'vue'
import {  ElPagination } from 'element-plus'
import {getLog} from '@/api/log'

const tableData = ref([])

const getLogApi = async () => {
  const result = await getLog(currentPage.value,pageSize.value)
  if(result.code){
    tableData.value = result.data.rows
    total.value = result.data.total
  }
}

onMounted(() => {
  getLogApi()
})


//分页
const currentPage = ref(1)
const pageSize = ref(10)
const background = ref(false)
const total = ref(0)

const handleSizeChange = (val) => {
  getLogApi()
}
const handleCurrentChange = (val) => {
  getLogApi()
}
</script>

<template>
  <h1>日志管理</h1>
  <div class="table">
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="id" label="id" width="70" align="center" />
      <el-table-column prop="operateEmpId" label="操作人id" width="100" align="center" />
      <el-table-column prop="operateTime" label="操作时间" width="120" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="className" label="类名" width="200" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="methodName" label="方法名" width="200" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="methodParams" label="方法请求参数" width="200" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="returnValue" label="返回值" width="200" align="center" :show-overflow-tooltip="true" />
      <el-table-column prop="costTime" label="执行耗时，单位ms" width="150" align="center" />
      <el-table-column prop="operateEmpName" label="操作人姓名" align="center" />
    </el-table>
  </div>
  <div class="demo-pagination-block">
    <el-pagination
      v-model:current-page="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[50, 100, 200, 300]"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<style scoped>
.demo-pagination-block {
  margin: 20px 0 0 350px;
}
.table{
  margin: 20px 0 0 0;
}
</style>